1
2
3
4
5
6
7 package ca.uhn.cache.proxy.impl;
8
9 import java.lang.reflect.Method;
10
11 import ca.uhn.cache.CacheReasonEnum;
12 import ca.uhn.cache.proxy.IDataInspector;
13 import ca.uhn.cache.proxy.IMethodAdapter;
14
15 /***
16 * Base implementation of IMethodAdapter.
17 *
18 * @author <a href="mailto:bryan.tripp@uhn.on.ca">Bryan Tripp</a>
19 * @version $Revision: 1.1 $ updated on $Date: 2005/01/24 22:53:38 $ by $Author: bryan_tripp $
20 */
21 public abstract class AbstractMethodAdapter implements IMethodAdapter {
22
23 private String myMethodName;
24 private Class[] myArgTypes;
25 private int myMaxGroups;
26 private IDataInspector myInspector;
27
28 /***
29 * @param theMethodName name of the method to be wrapped
30 * @param theArgTypes classes of arguments (in order) of method to be wrapped
31 * @param theMaxGroups maximum number of allowed queries with which to express a remainder
32 * (generally, more means more queries but fewer un-needed results)
33 * @param theInspector expressor of method arguments as IQueryParams
34 */
35 public AbstractMethodAdapter(String theMethodName, Class[] theArgTypes,
36 int theMaxGroups, IDataInspector theInspector) {
37 myMethodName = theMethodName;
38 myArgTypes = theArgTypes;
39 myMaxGroups = theMaxGroups;
40 myInspector = theInspector;
41 }
42
43 /***
44 * @param theMethod the method to be wrapped
45 * @param theMaxGroups maximum number of allowed queries with which to express a remainder
46 * (generally, more means more queries but fewer un-needed results)
47 * @param theInspector expressor of method arguments as IQueryParams
48 */
49 public AbstractMethodAdapter(Method theMethod, int theMaxGroups, IDataInspector theInspector) {
50 myMethodName = theMethod.getName();
51 myArgTypes = theMethod.getParameterTypes();
52 myMaxGroups = theMaxGroups;
53 myInspector = theInspector;
54 }
55
56 /***
57 * @see ca.uhn.cache.proxy.IMethodAdapter#getMethodName()
58 */
59 public String getMethodName() {
60 return myMethodName;
61 }
62
63 /***
64 * @see ca.uhn.cache.proxy.IMethodAdapter#getArgTypes()
65 */
66 public Class[] getArgTypes() {
67 return myArgTypes;
68 }
69
70 /***
71 * @see ca.uhn.cache.proxy.IMethodAdapter#getMaxGroups()
72 */
73 public int getMaxGroups() {
74 return myMaxGroups;
75 }
76
77 /***
78 * Defaults to CacheReasonEnum.QUERY.
79 *
80 * @see ca.uhn.cache.proxy.IMethodAdapter#getReason(java.lang.Object[])
81 */
82 public CacheReasonEnum getReason(Object[] theMethodArgs) {
83 return CacheReasonEnum.QUERY;
84 }
85
86 /***
87 * @see ca.uhn.cache.proxy.IMethodAdapter#getDataInspector()
88 */
89 public IDataInspector getDataInspector() {
90 return myInspector;
91 }
92
93 }